package com.monitor.controller;


import com.monitor.entity.ErpCustomerFinianceAccounts;
import com.monitor.service.ErpCustomerFinianceAccountsService;
import com.monitor.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 客户财务账目表 前端控制器
 * </p>
 *
 * @author LX
 * @since 2018-09-06
 */
@RestController
@RequestMapping("/erpCustomerFinianceAccounts")
@Api(description="客户财务账目")
public class ErpCustomerFinianceAccountsController {

    @Resource
    private ErpCustomerFinianceAccountsService accountsService;

    @RequestMapping("/inertOrUpdateCustAccounts")
    @ApiOperation("添加Or修改客户财务账目信息")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "customerCode", value = "客户编号", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "custId", value = "客户ID", required = false, dataType = "int", paramType = "query")*/
    })
    public @ResponseBody
    Result<ErpCustomerFinianceAccounts> inertOrUpdateCustAccounts(ErpCustomerFinianceAccounts customerCar) {
        Result<ErpCustomerFinianceAccounts> result=new Result<ErpCustomerFinianceAccounts>();
        try{
            accountsService.insertOrUpdate(customerCar);
            result.setCount(1);
            result.setData(customerCar);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }

    @RequestMapping("/removeCustAccounts")
    @ApiOperation("删除客户财务账目信息")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "customerCode", value = "客户编号", required = false, dataType = "int", paramType = "query"),*/
            @ApiImplicitParam(name = "customerCarId", value = "客户财务账目ID", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<Integer> removeCustAccounts(Integer customerCarId) {
        Result<Integer> result=new Result<Integer>();
        try{
            result.setCount(1);
            result.setData(accountsService.deleteById(customerCarId)?1:0);
        }catch (Exception e){e.printStackTrace();}
        return result;
    }


}

